﻿using System;

namespace 四道计算题
{
    class Program
    {
        static void Main(string[] args)
        {
            //1.百元买鸡
            Console.WriteLine("百钱买鸡:");
            int gj, mj, xj;
            for (gj = 0; gj <= 100; gj++)
            {
                for (mj = 0; mj <= 100; mj++)
                {
                    for (xj = 0; xj <= 100; xj++)
                    {
                        if ((gj + mj + xj == 100) && (5 * gj + 3 * mj + xj / 3 == 100) && (xj % 3 == 0))
                        {
                            Console.WriteLine("买了公鸡{0}只,母鸡{1}只,小鸡{2}只", gj, mj, xj);
                        }
                    }
                }
            }
            Console.WriteLine();

            //2生日时间
            Console.WriteLine("生日时间:");
            int fu, mu, x, d;
            for (fu = 0; fu < 78; fu++)
            {

                for (mu = 0; mu < 78; mu++)
                {

                    for (x = 0; x < 17; x++)
                    {
                        for (d = 0; d < 17; d++)
                        {
                            if ((fu + mu == 78) && (x + d == 17) && (fu + 4 == 4 * (d + 4)) && (mu + 4 == 3 * (x + 4)))
                            {
                                int year = (fu - 3 * x) / 2;
                                Console.WriteLine("公元{0}年", 1998 + year);
                            }
                        }

                    }
                }
            }
            Console.WriteLine();
            //3.鸡兔同笼问题
            Console.WriteLine("3.鸡兔同笼问题");
            Console.WriteLine("已知鸡兔总头数为x，总脚数为y，求鸡兔各有多少只？");
            int x = 35;
            int y = 94;
            for (int chicken = 0; chicken < y / 2; chicken++)
            {
                for (int rabbit = 0; rabbit < y / 4; rabbit++)
                {
                    if ((chicken + rabbit == x) && (chicken * 2 + rabbit * 4 == y))
                    {
                        Console.WriteLine($"鸡一共有：{chicken},兔一共有：{rabbit}");
                        break;
                    }
                }
            }
            Console.ReadKey();
            //百钱买鸡
              
            
            //4.答题算数
            Console.WriteLine("答题算数:");
            for (int i = 0; i < 52; i++)
            {
                for (int j = 0; j < 52; j++)
                {
                    int a = 2 * i + 7 + 6 + j;
                    int b = 5 * i + 5 * 6 + 7 + 4 * j;
                    if (a == 52 && b == 181)
                    {
                        Console.WriteLine("答对四道的有{0}人", j);
                    }
                }
            }
            Console.ReadKey();
        }
    }
}
        
